#include "GameMessageId.h"
#include "GameMessage.h"


unsigned char* GameMessage::toCharPointer(){
	char* returnable = new char[(sizeof(GameMessageId)+ sizeof(messageStr))];
	returnable[0] = messageId;
	strcpy(&(returnable[1]),messageStr.C_String());
	return (unsigned char*)returnable;
}

GameMessage::GameMessage(unsigned char* in)
{
	this->messageId = (GameMessageId)in[0];
	this->messageStr = RakNet::RakString((char*)&(in[1]));
}

GameMessage::GameMessage(GameMessageId messageId, std::string messageStr)
{
	this->messageId = messageId;
	this->messageStr = RakNet::RakString(messageStr.c_str());
}

std::string GameMessage::getMessageStr()
{
	return std::string(messageStr.C_String());
}


void GameMessage::setMessage(unsigned char* in)
{
	this->messageId = (GameMessageId)in[0];
	this->messageStr = RakNet::RakString((char*)&(in[1]));
}